Allah(swt) has given the servant the authority to do good and evil by telling the straight path in His book(Quran). If he misuses his authority and fulfills his desire in a Forbidden way, then it is as if it was a test from Allah for this servant, and this servant committed a sin by disobeying Allah and misused his authority.