We have to bury/cremate the dead so a funeral process is required. This can be confirmed by:-
9:84 Nor shall you (O Prophet) follow the funeral of any of them that dies, nor stand at his grave. They rejected God and His Messenger, and drifted away from the Commands until they died.
The Messenger was not allowed to attend the funeral of the hypocrites and so we can, by implication, say that he and us are allowed to attend funerals.
Janaza is the ritual we have today that requires us to pray for forgiveness for the deceased which has no Quranic foundation. Allah has clearly stated that He will hold us accountable for our actions and no injustice will be done. This means that no amount of prayers will change this decision.
The only reason for any sort of prayer would be for consoling the living, to bring closure for someone we once knew. Any form of personal prayer, any words that make you feel better, is a choice appropriate for you; it is not something that can or should be ritualised.
As for the forty day and one year khutams we see, these are appalling burdens placed upon the grieving family to provide a slap up meal for people on the pretext that they are respecting the dead! Let the funeral be the last event in the procedure and let the dead, and the living, rest.