When you walk close to God and Jesus is in your heart you will know immediately whether something is right or wrong, just or unjust, godly or ungodly because Jesus is communicating with you all the time. The Holy Spirit will lead you and guide you and He will warn you whenever something is not right.
In this Beatitude Jesus said to HUNGER and THIRST after RIGHTEOUSNESS. Hunger and Thirst are appetites that return to us every day, and frequently during the day. Your living body requires to be fed healthy food so that it can continue to be strong throughout the day. When we walk with God in righteousness our Soul requires and desires to be feed with constant meals throughout the day. These are meals of righteousness to walk daily with God, to do the will of God, and to be like Jesus.
When Jesus Christ lives within your heart you have a desire to seek to walk in righteousness and to lead a Godly life every second of the day. For a righteous person knows that God's way of life is what fills you with peace and joy. You realize that nothing can be more perfect, more pure, and more pleasing to Our Heavenly Father then living a life that God totally approves of.