There are few texts of scripture that so clearly set out the sacrifice of Jesus so clearly than by contrasting what Jesus wanted to achieve vs the pain of execution. The joy set before Jesus was his goal in redeeming the human race for no other reason than love (1 John 4:8, 16). Ellicott summarises this well:
Who for the joy that was set before him endured the cross.--The
literal meaning is very forcible, endured a cross, despising shame;
the shame of such a death being set over against the joy that lay
before Him. Here again we have the thought of Hebrews 2:9 (Philippians
2:9-10); the joy of His accomplished purpose (Isaiah 53:11; Matthew
25:21; Luke 10:21-22) and the glory with which He was crowned (John
17:1; 1Peter 1:11) being the reward for His "obedience even unto
death." The whole form of the expression (comp. especially Hebrews
6:18, "the hope set before us") shows that Jesus is presented to us as
an example not of endurance only, but also of faith (Hebrews 2:12).
Thus, Jesus not only accomplished His purpose to save humanity but also set an example (1 Peter 2:21; John 13:15, Eph 4:32, 5:1; Col 3:1-3) that we are instructed to fix our attention to (Heb 12:2, 3) and thus have the mind of Christ (1 Cor 2:16). See also Meyers NY commentary on this verse.