Solomon's Wisdon a cameron production
After marrying the daughter of the Pharaoh, Solomon was making sacrifices to the LORD, and the LORD contacted him in a dream. He said to Solomon, "whatever you ask, I shall give you."
Solomon tells the LORD that he is young, and has many people to take care of. So he asks God for the wisdom to distinguish good and evil, and to effectively give judgement tot he people of Israel. The LORD was pleased that Solomon made this request, because his wisdom was for the good of the people of Israel.
Wisdom gives Solomon the power to know the difference between good and evil while giving judgement to his people. This is also important, because Solomon was young and inexperienced as a leader, and he needed to wisdom from God to effectively rule.

Soon after Solomon received this wisdom from the LORD, two arguing concubines came to him. The woman gave birth around the same time, and they each slept with their respective baby. One of the woman was being a responsible parent and suffocated the baby in its sleep, so she switched out her dead son for the other woman's living son. Both woman claimed that the baby was theirs.
So Solomon gives her the baby, because his wisdom helps him know that only the mother would say that. This was David's first test of wisdom.