(Assuming this wasn't just a network slowdown or transaction backlog... )
A miner doesn't have to include your transaction in a block if he/she doesn't want to - you have to pay them to do so.
When you send a transaction and the associated gas to the network, you enter a market. If the amount of gas (i.e. mining fees) that you sent with your transaction is less than the gas that other people sent with their transactions, then your transaction will be priced out of the "Please Include My Transaction in a Block" market. Your transaction will sit in Pending state until the market price decreases.
The more gas you send with your transaction, the higher in priority the miners will treat it.