Optimization in Function Spaces: With Stability Considerations in Orlicz Spaces