For the apple compote: Set a medium saute pan over medium-high heat. Add the butter and green apples. Saute until the apples soften, 1 to 2 minutes, and then add the raisins, sugar, cinnamon, nutmeg and lemon juice. Add 1/4 cup of water and simmer until the apples are cooked through and the raisins are plumped, about 5 minutes. Set the compote aside to cool on a plate.
For the tamales: Mix the masa harina, 1 1/4 cups water, butter, salt and agave into a thick paste. Fold the apple compote into the masa mixture.
Set a corn husk out on a flat surface (double up or shingle 2 husks if they are small or have tears). Add 5 tablespoons of the masa mix into the center of the corn husk. Push the mixture to 1 inch from the side of the husk. Fold one edge of the husk to the center and then fold the other side to cover the entire tamale. Fold the ends over by 2 inches and tuck under to hold in place.
Place a colander in large pot of boiling water, but do not let the colander touch the water. Place the tamales in the colander, cover and steam the tamales for 30 to 40 minutes.
Serve the tamales topped with vanilla ice cream and a drizzle of caramel.