To solve this optimization problem, we need to define the decision variables, the objective function, and the constraints.

Let's denote:
- $x_y$ as the amount invested in the younger sister's company.
- $x_e$ as the amount invested in the elder sister's company.

The objective is to maximize the total profit. Given that each dollar invested in the younger sister's company yields a profit of $0.05 and each dollar invested in the elder sister's company yields a profit of $0.08, the total profit can be represented as $0.05x_y + 0.08x_e$.

There are several constraints:
1. The total investment is $5000, so $x_y + x_e \leq 5000$.
2. At least 40% of the investment should go to the younger sister's company, which can be represented as $x_y \geq 0.4 \times (x_y + x_e)$ or simplified as $x_y \geq 0.4 \times 5000$ since the total investment is fixed at $5000. However, this simplification might not fully capture the intent if the total investment could be less than $5000, but given our first constraint, it's a reasonable approach.
3. At least $2000 should be invested in the elder sister's company, so $x_e \geq 2000$.

Given these constraints and the objective function, we aim to find the values of $x_y$ and $x_e$ that maximize profit.

Here is how you can translate this problem into Gurobi code in Python:

```python
from gurobipy import *

# Create a model
m = Model("Investment_Optimization")

# Define variables
x_y = m.addVar(name='younger_sister_investment', lb=0)  # Investment in younger sister's company
x_e = m.addVar(name='elder_sister_investment', lb=0)    # Investment in elder sister's company

# Objective function: Maximize profit
m.setObjective(0.05*x_y + 0.08*x_e, GRB.MAXIMIZE)

# Constraints
m.addConstr(x_y + x_e <= 5000, name='total_investment')         # Total investment is $5000
m.addConstr(x_y >= 0.4 * 5000, name='minimum_younger_sister')   # At least 40% of $5000 in younger sister's company
m.addConstr(x_e >= 2000, name='minimum_elder_sister')           # At least $2000 in elder sister's company

# Solve the model
m.optimize()

# Print solution
if m.status == GRB.OPTIMAL:
    print(f"Optimal investment in younger sister's company: ${x_y.x}")
    print(f"Optimal investment in elder sister's company: ${x_e.x}")
    print(f"Maximum profit: ${m.objVal}")
else:
    print("No optimal solution found")
```