1)
Why does it say "Rak"?
1.
Malbim: You are lacking only building it in action, but you are credited as if you built it, due to your good intent.
2)
Why did He say that David's son will build the Bayis Lishmi?
1.
Malbim (17): This is why David could not build it, for he had many wars, and he knew that building it would bring serenity from war. He could not build it totally l'Shem Hashem, for he himself would benefit from it. Shlomo had serenity in any case, so he had no ulterior motive.