The greatest command is found first in Deuteronomy.
“Hear, O Israel: The LORD our God, the LORD is One.
And you shall love the LORD your God with all your heart and with all your soul and with all your strength.
These words I am commanding you today are to be upon your hearts. And you shall teach them diligently to your children and speak of them when you sit at home and when you walk along the road, when you lie down and when you get up. Tie them as reminders on your hands and bind them on your foreheads. Write them on the doorposts of your houses and on your gates.”
Deuteronomy 6:4-9
The second greatest command is found first in Leviticus.
“You shall not hate your brother in your heart, but you shall reason frankly with your neighbor, lest you incur sin because of him. You shall not take vengeance or bear a grudge against the sons of your own people, but you shall love your neighbor as yourself: I am the Lord.
Leviticus 19:17-18
We know that these are the two greatest commands because Jesus tells us in the gospels of Matthew and Mark.
But when the Pharisees heard that he had silenced the Sadducees, they gathered together. And one of them, a lawyer, asked him a question to test him. “Teacher, which is the great commandment in the Law?” And he said to him, “You shall love the Lord your God with all your heart and with all your soul and with all your mind. This is the great and first commandment. And a second is like it: You shall love your neighbor as yourself. On these two commandments depend all the Law and the Prophets.”
Matthew 22:34-39
And one of the scribes came up and heard them disputing with one another, and seeing that he answered them well, asked him, “Which commandment is the most important of all?” Jesus answered, “The most important is, ‘Hear, O Israel: The Lord our God, the Lord is one. And you shall love the Lord your God with all your heart and with all your soul and with all your mind and with all your strength.’ The second is this: ‘You shall love your neighbor as yourself.’ There is no other commandment greater than these.”
Mark 12:28-31