Let's forget about Melo and Dwight a bit and use a young and upcoming player as an example. If he is good enough for the team, he will be drafted and will get a guaranteed contract. If he isn't good for the team but the management thinks there's a 50-50 chance that the player can improve, the non-guaranteed contract can be used by the team and see if it will work out or not. If it works, he'll get a better contract. If it doesn't, then that player has to work even harder. That is still fair for both parties.
If we're going to talk about veterans who're getting non-guaranteed contracts now, remember that they once had a guaranteed contract and earned a lot from it. They already got paid a good amount of money for their hard work.